package com.homeparking.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.homeparking.common.annotation.Log;
import com.homeparking.common.core.controller.BaseController;
import com.homeparking.common.core.domain.AjaxResult;
import com.homeparking.common.enums.BusinessType;
import com.homeparking.manage.domain.ManageHouseAgent;
import com.homeparking.manage.service.IManageHouseAgentService;
import com.homeparking.common.utils.poi.ExcelUtil;
import com.homeparking.common.core.page.TableDataInfo;

/**
 * 经纪人管理Controller
 * 
 * @author liuyangyang
 * @date 2025-10-12
 */
@RestController
@RequestMapping("/manage/manage_house_agent")
public class ManageHouseAgentController extends BaseController
{
    @Autowired
    private IManageHouseAgentService manageHouseAgentService;

    /**
     * 查询经纪人管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:manage_house_agent:list')")
    @GetMapping("/list")
    public TableDataInfo list(ManageHouseAgent manageHouseAgent)
    {
        startPage();
        List<ManageHouseAgent> list = manageHouseAgentService.selectManageHouseAgentList(manageHouseAgent);
        return getDataTable(list);
    }

    /**
     * 导出经纪人管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:manage_house_agent:export')")
    @Log(title = "经纪人管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ManageHouseAgent manageHouseAgent)
    {
        List<ManageHouseAgent> list = manageHouseAgentService.selectManageHouseAgentList(manageHouseAgent);
        ExcelUtil<ManageHouseAgent> util = new ExcelUtil<ManageHouseAgent>(ManageHouseAgent.class);
        util.exportExcel(response, list, "经纪人管理数据");
    }

    /**
     * 获取经纪人管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:manage_house_agent:query')")
    @GetMapping(value = "/{houseAgentId}")
    public AjaxResult getInfo(@PathVariable("houseAgentId") String houseAgentId)
    {
        return success(manageHouseAgentService.selectManageHouseAgentByHouseAgentId(houseAgentId));
    }

    /**
     * 新增经纪人管理
     */
    @PreAuthorize("@ss.hasPermi('manage:manage_house_agent:add')")
    @Log(title = "经纪人管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ManageHouseAgent manageHouseAgent)
    {
        return toAjax(manageHouseAgentService.insertManageHouseAgent(manageHouseAgent));
    }

    /**
     * 修改经纪人管理
     */
    @PreAuthorize("@ss.hasPermi('manage:manage_house_agent:edit')")
    @Log(title = "经纪人管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ManageHouseAgent manageHouseAgent)
    {
        return toAjax(manageHouseAgentService.updateManageHouseAgent(manageHouseAgent));
    }

    /**
     * 删除经纪人管理
     */
    @PreAuthorize("@ss.hasPermi('manage:manage_house_agent:remove')")
    @Log(title = "经纪人管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{houseAgentIds}")
    public AjaxResult remove(@PathVariable String[] houseAgentIds)
    {
        return toAjax(manageHouseAgentService.deleteManageHouseAgentByHouseAgentIds(houseAgentIds));
    }
}
